﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using MethodWorx.CMS.UI.Application.ActionResults;
using System.Web;

namespace MethodWorx.CMS.Plugins.ActionResults
{
    public class TabResult : AppJavaScriptResult
    {
        public TabResult(params string[] items)
            : base(GetScript(items))
        {
        }

        private static string GetScript(string[] items)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("clearTabs();");
            for (var i = 0; i < items.Length; i += 2)
            {
                sb.Append("insertTab('" + i + "', '" + items[i] + "', resolveUrl('" + items[i + 1] + "'));");
            }

            sb.Append("bindTabs();resizeIFrame();");
            return sb.ToString();
        }
    }
}
